
#include "ros/ros.h"
#include "cre/CreServiceMsgRequest.h"
#include "cre/CreServiceMsgResponse.h"
#include "cre/CreServiceMsg.h"

int main(int argc, char **argv) {
    ros::init(argc, argv, "cre_service_client");
    ros::NodeHandle nh;

    // 创建一个 ROS 服务客户端，请求 my_service 服务
    ros::ServiceClient client = nh.serviceClient<cre::CreServiceMsg>("cre_service");

    // 创建一个请求消息
    cre::CreServiceMsg srv;
    srv.request.input = 42;
    if (client.call(srv)) {
        ROS_INFO("Service response: %ld", (long int) srv.response.output);  // 输出响应结果
    } else {
        ROS_ERROR("Failed to call service my_service");
        return 1;
    }

    return 0;
}
